<?php

namespace app\api;

use plugin\admin\app\model\WorldResource;
use support\Cache;
use support\Response;

class WorldController
{
    public $data = [];

    public function getTree()
    {
        return  json(['world_tree' => Cache::get('world_tree')]);
    }

    public function getResource()
    {
        $resource = WorldResource::query()->where('status', 1)->get();

        foreach($resource as $k=>$item) {
            $this->data[$k]['resource_name'] = $item->name;
            $this->data[$k]['resource_value'] = $item->value;
            $this->data[$k]['resource_add'] = $item->add;
            $this->data[$k]['resource_status'] = $item->status;
        }

        return json([$this->data]);
    }
}